package 蓝桥真题;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class 子串分值和 {
       static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
       final static int N=100010;
       static char str[]=null;
       
       public static void main(String[] args) throws IOException {
    	      String line = br.readLine();
    	      int n=line.length();
		      str=(" "+line).toCharArray();
		      long res=0;
		      for(int i=1;i<=n;i++){
		    	  int pi=i-1;
		    	  while(pi>0&&str[pi]!=str[i]){
		    		   pi--;
		    	  }
		    		  pi+=1;
		    		  int l=i-pi+1,r=n-i+1;
		    		  res+=1L*l*r;
		      }
		      System.out.print(res);
	}
}
